<?php
class PlantVo extends SzAbstractMySqlVo
{

    private $decorId;
    private $userId;
    private $seedId;
    private $harvestTime;
    private $status;
    private $harvestCount;
    private $stealInfo;
    private $level;

    /**
     * Initialize PlantVo.
     *
     * @param $decorId
     * @param $userId
     * @param $seedId
     * @param $harvestTime
     * @param $status
     * @param $harvestCount
     * @param $stealInfo
     * @param $level
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return PlantVo
     */
    public function __construct($decorId, $userId, $seedId, $harvestTime, $status, $harvestCount, $stealInfo, $level, $isInsert = false) {
        $this->decorId = $decorId;
        $this->userId = $userId;
        $this->seedId = $seedId;
        $this->harvestTime = $harvestTime;
        $this->status = $status;
        $this->harvestCount = $harvestCount;
        $this->stealInfo = json_decode($stealInfo, true);
        $this->level = $level;

        $this->isInsert = $isInsert;
        $this->voClassName = 'PlantVo';
        $this->ormName = 'Plant';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'decorId' => $this->getDecorId(),
            'userId' => $this->getUserId(),
            'seedId' => $this->getSeedId(),
            'harvestTime' => $this->getHarvestTime(),
            'status' => $this->getStatus(),
            'harvestCount' => $this->getHarvestCount(),
            'stealInfo' => ($needEncode) ? $this->getStealInfo() : $this->getRawStealInfo(),
            'level' => $this->getLevel(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'decorId' => $this->getDecorId(),
            'userId' => $this->getUserId(),
            'seedId' => $this->getSeedId(),
            'harvestTime' => $this->getHarvestTime(),
            'status' => $this->getStatus(),
            'harvestCount' => $this->getHarvestCount(),
            'stealInfo' => ($needEncode) ? $this->getStealInfo() : $this->getRawStealInfo(),
            'level' => $this->getLevel(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getDecorId(),
            $this->getUserId(),
            $this->getSeedId(),
            $this->getHarvestTime(),
            $this->getStatus(),
            $this->getHarvestCount(),
            $this->getStealInfo(),
            $this->getLevel(),
        );
    }

    public function getDecorId()
    {
        return $this->decorId;
    }

    public function setDecorId($val)
    {
        $this->saveColumnStatus(0, $this->decorId);
        $this->decorId = $val;
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(1, $this->userId);
        $this->userId = $val;
    }

    public function getSeedId()
    {
        return $this->seedId;
    }

    public function setSeedId($val)
    {
        $this->saveColumnStatus(2, $this->seedId);
        $this->seedId = $val;
    }

    public function getHarvestTime()
    {
        return $this->harvestTime;
    }

    public function setHarvestTime($val)
    {
        $this->saveColumnStatus(3, $this->harvestTime);
        $this->harvestTime = $val;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function setStatus($val)
    {
        $this->saveColumnStatus(4, $this->status);
        $this->status = $val;
    }

    public function getHarvestCount()
    {
        return $this->harvestCount;
    }

    public function setHarvestCount($val)
    {
        $this->saveColumnStatus(5, $this->harvestCount);
        $this->harvestCount = $val;
    }

    public function getStealInfo()
    {
        return json_encode($this->stealInfo);
    }

    public function getRawStealInfo()
    {
        return $this->stealInfo;
    }

    public function setStealInfo($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 1024) {
            SzLogger::get()->error('[PlantVo] The length of column stealInfo exceed the limit, length / limit: ' . $encodedLength . ' / 1024');
            throw new SzException(10522, array('PlantVo', '1024', $encodedLength));
        } else if ($encodedLength > 921) {
            SzLogger::get()->warn('[PlantVo] The length of column stealInfo exceed the warning level, length / limit: ' . $encodedLength . ' / 1024');
        }
        $this->saveColumnStatus(6, $this->stealInfo);
        $this->stealInfo = $val;
    }

    public function getLevel()
    {
        return $this->level;
    }

    public function setLevel($val)
    {
        $this->saveColumnStatus(7, $this->level);
        $this->level = $val;
    }

}